//
//  NSObject+category.m
//  runtime
//
//  Created by zxy on 2018/4/17.
//  Copyright © 2018年 zssh. All rights reserved.
//

#import "NSObject+category.h"
#import <objc/runtime.h>
char nameKey;
@implementation NSObject (category)
-(void)setName:(NSString *)name{
    // 将name属性跟NSObject对象关联起来，将name属性存储到NSObject对象中
    objc_setAssociatedObject(self, &nameKey, name, OBJC_ASSOCIATION_COPY_NONATOMIC);
}

-(NSString *)name{
    /*从key获取对象*/
    return objc_getAssociatedObject(self,&nameKey);
}
@end
